<template>
  <div class="container">
    <error-tip :errorCode="errorCode" v-if="errorCode"></error-tip>
    <div v-else>
      <card-list :data="monthData"></card-list>
    </div>
  </div>
</template>

<script>
import { computed, onMounted } from "vue";
import { useStore } from "vuex";
import { getNowDate } from "../libs/utils";
import getData from "../services";
import CardList from "../components/MonthPage/List";

export default {
  setup() {
    const store = useStore();

    onMounted(() => {
      const field = store.state.field;
      getData(store, field, getNowDate(field));
    });
    return {
      monthData: computed(() => store.state.monthData),
      errorCode: computed(() => store.state.errorCode),
    };
  },
  components: {
    CardList,
  },
};
</script>

<style lang="less" scoped></style>
